package com.alibaba.cirtus.ots.application.adapter.ability.utils;

import lombok.Data;

import java.math.BigDecimal;

/**
 * @author zhoubc
 * @description: TODO
 * @date 2021/12/27 10:28
 */
@Data
public class PageRecordUtil {

    private int pageSize = 1000;

    private int start;

    private int page;

    private int sortNo;

    private int lastSameSortNo;

    private BigDecimal lastTaskCountCompletePercentage;

    private BigDecimal lastMonthMoneyCompletePercentage;

    private BigDecimal lastMoney;

    public void simpleResetPageParam(){
        start = 0;
        page = 1;
    }

    public void resetPageParam(){
        start = 0;
        page = 1;
        sortNo = 1;
        lastSameSortNo = -1;
        lastTaskCountCompletePercentage = new BigDecimal(-1);
        lastMonthMoneyCompletePercentage = new BigDecimal(-1);
        lastMoney = new BigDecimal(-1);
    }

    public void turnPage(){
        start += pageSize;
    }

    public void setTotalPages(int total){
        page = (total + pageSize - 1)/pageSize;
    }

    public void sortNoIncrease(){
        sortNo++;
    }

    public void recordTaskCountCompletePercentage(BigDecimal number){
        lastTaskCountCompletePercentage = number;
    }

    public void recordlastMonthMoneyCompletePercentage(BigDecimal number){
        lastMonthMoneyCompletePercentage = number;
    }

    public void recordlastMoney(BigDecimal number){
        lastMoney = number;
    }

    public Integer getNewSortNoAndRecordLastSortNo(){
        lastSameSortNo = sortNo;
        return sortNo;
    }

}
